using System;
using System.Collections;
using MySql.Data.MySqlClient;

namespace Scenario.Modules.PCM.Database
{
	public class BaseDataTypes 
	{
		public const string TYPE_INTEGER	= "INTEGER";
		public const string TYPE_DOUBLE		= "DOUBLE";
		public const string TYPE_BIT		= "BIT";
		public const string TYPE_STRING		= "STRING";
		public const string TYPE_DATE		= "DATE";

		public const string DIRECTION_EQ	= "=";
		public const string DIRECTION_NE	= "!=";
		public const string DIRECTION_LS	= "<";
		public const string DIRECTION_LE	= "<=";
		public const string DIRECTION_GR	= ">";
		public const string DIRECTION_GE	= ">=";
	

		public static string getEnglishDate(DateTime date)
		{
			string ret=string.Empty ;

			ret = date.Year + "/" + date.Month + "/" + date.Day;

			return ret;
		}

		public static string getDecimalValue(decimal val)
		{
			string sVal = val.ToString();
			sVal = sVal.Replace(".","");
			sVal = sVal.Replace(",",".");
			return sVal;
		}

	}


	public class BasicBusinessObject : bOS.DataBase.bOSTable
	{
		private int iId = -1;
		private int iIdSupplier = -1;
		private string sItem = string.Empty;
		private decimal dPrice = 0;
		private string sCaracteristics = string.Empty;

		private const string COLOR_CARACTERISTICS = "Color";

		public int Id
		{
			get { return this.iId;}
			set { this.iId = value;}
		}

		public int IdSupplier
		{
			get { return this.iIdSupplier;}
			set { this.iIdSupplier = value;}
		}

		public string Item
		{
			get { return this.sItem;}
			set { this.sItem = value;}
		}

		public decimal Price
		{
			get { return this.dPrice;}
			set { this.dPrice = value;}
		}

		public string Caracteristics
		{
			get { return this.sCaracteristics;}
			set { this.sCaracteristics=value;}
		}

		#region Caracteristics Method
		public bool ColorAssociated()
		{
			if ( this.sCaracteristics.IndexOf(BasicBusinessObject.COLOR_CARACTERISTICS) >= 0 )
				return true;
			
			return false;
		}
		#endregion

        public void ReadFromDataBase(MySqlDataReader reader)
		{
			this.Id = reader.GetInt32(0);	
			this.IdSupplier = reader.GetInt32(1);
			this.Item = reader.GetString (2);
			this.Price = reader.GetDecimal(3);
			//4 OptionType
			this.Caracteristics = reader.GetString (5);
		}
	}

	
	
}
